// 模板层
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

// 创建一个映射表
const UserSchema = new Schema({
    name: {
        type: String,
        required: true,
        //主键
        unique: true
    },
    email: {
        type: String,
        required: true
    },
    password: {
        type: String,
        required: true
    },
    isAdmin:{
        type: Boolean,
        default:false,
    },
    meta: {
        type: Date,
        default: Date.now()
    }
}, {
    collection: 'User', versionKey: false
})

// 在mongodb里生成一个映射表并抛出
module.exports = mongoose.model('User', UserSchema)
